package com.thread;

/**
 * 跟006 是一个意思
 */
public class ThreadSingleClass007 {
    private static ThreadSingleClass007 instance;

    /**
     * 用到了才初始化
     */
    static {
        instance = new ThreadSingleClass007();
    }
    private ThreadSingleClass007(){}

    public static ThreadSingleClass007 getInstance(){
        return instance;
    }

    public static void main(String[] args) {
        ThreadSingleClass007 m1 = ThreadSingleClass007.getInstance();
        ThreadSingleClass007 m2 = ThreadSingleClass007.getInstance();
        System.out.println(m1);
        System.out.println(m2);

        System.out.println(m1==m2);
    }
}
